@extends('agent.mainlayout')
@section('title')
<div class="title"><span>审核管理(图片)></span></div>
@endsection
@section('content')
    <link rel="stylesheet" href="/style/public.css">
    <link rel="stylesheet" href="/style/home.css">
    <link rel="stylesheet" href="/style1/rili.css">
    <link rel="stylesheet" href="/static/js/layer/skin/layer.css">
    <style>
        .linka a:hover{

            color: red;
        }
        .linka a{
            text-decoration:underline;color: #1c9ed0;
        }

        .linka {

            position: relative;
            top: 10px;
            left: 120px;
        }

    </style>
    <div class="six">
        <div class="pic">
            <img id='img' src="/@if(empty($data['proxy'])){{'image/zhengshu.png'}}@else{{$data['proxy']}} @endif" alt="">
            <input id='hid' type="hidden" name="img">
            <p><a href="javascript:;">点击上传图片<input id='file' type="file" name="wenjian"></a></p>
        </div>
        <p class='linka'><a href="{{urlAdmin('Index','getDownImage')}}">样图下载</a>(请参考下载的样图,制作代理书上传)</p>
        <div class="btn" id="btn">提交</div>
    </div>
    <script>
        window.onload = function(){

            var oFile = document.getElementById('file');
            var oImg = document.getElementById('img');
            var oBtn = document.getElementById('btn');
            var oHide = document.getElementById('hid');
            //var oBox = document.getElementById('box');

            oFile.onchange = function(){

                var file = this.files[0];

                var reader = new FileReader();

                reader.readAsDataURL(file);   //将文件读取为DataUrl

                //读完了之后就能调取数据了
                reader.onload = function(){
                    //console.log(reader.result);
                    //将数据写入img标签
                    oImg.src=reader.result;
                    //在隐藏标签中添加value
                    oHide.value = reader.result;

                }

            }

            oBtn.onclick = function () {

                //console.log(url);
                var data = oHide.value;
                $.ajax({
                    type:"post",
                    url:"{{url('center/getimage/upload')}}",
                    dataType:"json",
                    data:{
                        img:data
                    },
                    success:function(res){
                        if(res['status']==1){

                            layer.msg(res.msg, {icon: 6});


                        }else{

                            layer.msg(res.msg, {icon: 5});

                        }
                    }
                });

            }

        }

    </script>
@endsection
